#ifndef WIJIUI_H
#define WIJIUI_H
#include <QtGui/QMainWindow>
#include <QSettings>
#include <QSize>
#include <QWebView>
#include <QFile>
#include "scripter.h"
#include <QScriptValue>
#include <QScriptable>
#include <QScriptEngine>
#include <QWebElement>
#include <QWebFrame>
#include "wijiuiscriptable.h"
#include "WijiSettings.h"
#include "WijiRPC.h"
class WijiUi : public QObject{
    Q_OBJECT
public:
    WijiUi(QMainWindow *parent = 0);
    static WijiUi* _self;
    static WijiUi* getSelf() {return _self;};
    static QWebView* getWebView() {return _self->webView;};
    static QString getCurrentHtml() { return _self->webView->page()->currentFrame()->toHtml();}
    static QWebFrame* getCurrentFrame() {return _self->webView->page()->currentFrame();};
    static QWebFrame* getMainFrame() {return _self->webView->page()->mainFrame();};
    static void init(QMainWindow *parent);
    int progress;
    Scripter scripter;
    QUrl baseUrl;
    QWebView *webView;
    QString jQuery;
    QMainWindow *parentObject;
    QScriptValue thisObject;
    QString javaScriptToRun;
    WijiRPC rpc;
public slots:
    void afterShow();
    void windowCloseRequested();
    void redirectTo(QString url);
    void finishLoading(bool);
    void notify(QString title,QString msg);
    void closeAll();
    void consoleLog(QString text);
    bool setContentOf(QString id, QString html);
    bool replaceWith(QString id, QString html);
    void linkClicked(QUrl url);
    void setWindowSize(int width, int height);
    void setHtml(QString contents,QString url);
    void addJavascriptObjects();
private:
    void connectSlots();
    void runInitScripts();
};
#endif // WIJIUI_H
